/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 阿宾
 * Date: 2025-02-26
 * Time: 14:57
 */
public class Test05 {

    public static void transform(int[] arr){
        for (int i = 0; i < arr.length; i++) {
            arr[i] = arr[i] * 2;
        }
    }
    public static void fun(int[] nums,int target){
        for (int i = 0; i < nums.length; i++) {
            for (int j = i+1; j < nums.length; j++) {
                if(nums[i] + nums[j] == target){
                    System.out.println("["+i+","+j+"]");
                }
            }
        }
    }
    public static int fun1(int[] num){
        int ret = 0;
        for (int i = 0; i < num.length; i++) {
            ret = ret ^ num[i];
        }
        return ret;
    }
    public static boolean fun2(int[] num) {
        int i = 2;
        int a = num[0];
        int b = num[1];
        int c = num[2];
        while (i < num.length-1) {
            if (a % 2 != 0 && b % 2 != 0 && c % 2 != 0) {
                return true;
            }
            a = b;
            b = c;
            i++;
            c = num[i];
        }
        return false;
    }


    public static void main(String[] args) {
        int[] arr = {2,6,4,1};
        System.out.println(fun2(arr));
    }




    /*
    在同一个类中定义多个方法：要求不仅可以求2个整数的最大值，还可以求3个小数的最大值？
     */
    public static int max2(int a,int b){
        return a > b ? a:b;
    }
    public static double max3(double a,double b,double c){
        double max = a > b ? a:b;
        if(max > c){
            return max;
        }else {
            return c;
        }
    }
    public static int sum(int num){//1234

        if(num > 9){
            return num % 10 + sum(num / 10);
        }
        return num % 10;
    }
    // 定义一个方法用于解决汉诺塔问题
    public static void hanoi(int n, char source, char auxiliary, char target) {
        // 如果只有一个圆盘，直接将其从源柱移动到目标柱
        if (n == 1) {
            System.out.println("Move disk 1 from " + source + " to " + target);
            return;
        }
        // 先将 n - 1 个圆盘从源柱借助目标柱移动到辅助柱
        hanoi(n - 1, source, target, auxiliary);
        // 再将第 n 个圆盘从源柱移动到目标柱
        System.out.println("Move disk " + n + " from " + source + " to " + target);
        // 最后将 n - 1 个圆盘从辅助柱借助源柱移动到目标柱
        hanoi(n - 1, auxiliary, source, target);
    }

    public static void main1(String[] args) {
        // 定义圆盘的数量为 4
        int n = 4;
        // 调用 hanoi 方法解决汉诺塔问题，初始时源柱为 'A'，辅助柱为 'B'，目标柱为 'C'
        hanoi(n, 'A', 'B', 'C');
    }
}
